import { createRouter, createWebHashHistory } from 'vue-router';
import type { RouteRecordRaw } from 'vue-router';


const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        redirect: '/login',
    },
    {
        path: '/login',
        name: 'login',
        // 路由懒加载
        component: () => import('../views/Login.vue'),
    },
    {
        path: '/home',
        name: 'home',
        component: () => import('../views/Home.vue'),
        children: [
            {
                path: 'welcome',
                name: 'welcome',
                // 路由懒加载
                component: () => import('../views/Welcome.vue'),
            },
            {
                path: 'users',
                name: 'users',
                component: () => import('../views/Users.vue'),
            },
            {
                path: 'roles',
                name: 'roles',
                component: () => import('../views/Roles.vue'),
            },
            {
                path: 'rights',
                name: 'rights',
                component: () => import('../views/Rights.vue'),
            }
        ],
        // 进入home页面直接重定向到/home/welcome
        redirect:'/home/welcome'
    },
];

const router = createRouter({
    history: createWebHashHistory(),
    routes
});

export default router;